﻿using MockDataAccess;
using System.Data;
using System;
using MockDataTransferObject;
using System.Collections.ObjectModel;

namespace MockBusiness
{
    public class TimesheetStatusBusiness
    {
        #region Initialize
        private static TimesheetStatusBusiness _instance;
        private readonly TimesheetStatusDataAccess _timesheetStatusDataAccess;

        /// <summary>
        /// Gets the timesheet status data test.
        /// </summary>
        public Collection<TimesheetStatus> TimesheetStatusDataTest
        {
            get
            {
                return _timesheetStatusDataAccess.AffectedRows;
            }
        }

        /// <summary>
        /// Prevents a default instance of the <see cref="TimesheetStatusBusiness"/> class from being created.
        /// </summary>
        private TimesheetStatusBusiness()
        {
            _timesheetStatusDataAccess = new TimesheetStatusDataAccess();
        }

        /// <summary>
        /// Prevents a default instance of the <see cref="TimesheetStatusBusiness"/> class from being created.
        /// </summary>
        /// <param name="isFake">if set to <c>true</c> [is fake].</param>
        private TimesheetStatusBusiness(bool isFake)
        {
            _timesheetStatusDataAccess = new TimesheetStatusDataAccess(isFake);
        }

        /// <summary>
        /// Retrieves the instance.
        /// </summary>
        /// <returns></returns>
        public static TimesheetStatusBusiness RetrieveInstance()
        {
            if (_instance == null)
                _instance = new TimesheetStatusBusiness();
            return _instance;
        }

        /// <summary>
        /// Retrieves the instance.
        /// </summary>
        /// <param name="isFake">if set to <c>true</c> [is fake].</param>
        /// <returns></returns>
        public static TimesheetStatusBusiness RetrieveInstance(bool isFake)
        {
            if (_instance == null)
                _instance = new TimesheetStatusBusiness(isFake);
            return _instance;
        }
        #endregion

        #region CUD
        #endregion

        #region R
        /// <summary>
        /// Retrieves all timesheet status.
        /// </summary>
        /// <returns></returns>
        public DataTable RetrieveAllTimesheetStatus()
        {
            return _timesheetStatusDataAccess.RetrieveAllTimesheetStatuses();
        }

        /// <summary>
        /// Gets the name of the status id by status.
        /// </summary>
        /// <param name="statusName">Name of the status.</param>
        /// <returns></returns>
        public object GetStatusIdByStatusName(string statusName)
        {
            if (statusName == null)
                return null;
            return _timesheetStatusDataAccess.GetStatusIdByStatusName(statusName);
        }

        /// <summary>
        /// Gets the name of the by status.
        /// </summary>
        /// <param name="statusName">Name of the status.</param>
        /// <returns></returns>
        public TimesheetStatus GetByStatusName(string statusName)
        {
            if (statusName == null)
                return null;
            return _timesheetStatusDataAccess.GetByStatusName(statusName);
        }
        #endregion
    }
}
